package br.fabrica.core;

import java.io.IOException;
import java.util.Stack;
import com.sun.lwuit.Form;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;

public class UIController {

	private static UIController instance;
	private Stack pilha;
	
	private UIController(){
		pilha = new Stack();
		
		try {
			Resources res = Resources.open("/MobileMarketTheme.res");
			UIManager.getInstance().setThemeProps(res.getTheme(res.getThemeResourceNames()[0]));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static UIController getInstance(){
		if(instance == null)
			instance = new UIController();
		return instance;
	}
	
	public void setCurrentDisplay(Form tela){
		pilha.push(tela);
		tela.show();
	}
	
	public void previousDisplay(){
		pilha.pop();
		Form previous = (Form) pilha.lastElement();
		previous.show();
	}
}
